﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IRongs.Wbt.Common.Attributes
{
    public class EnumStringAttribute : Attribute
    {
        public string Value { get; private set; }

        public EnumStringAttribute(string value)
        {
            this.Value = value;
        }

        public static string GetValue(Enum item)
        {
            object[] attrs = item.GetType().GetCustomAttributes(typeof(EnumStringAttribute), true);
            if (attrs == null || attrs.Length == 0)
                return item.ToString();

            EnumStringAttribute attr = attrs[0] as EnumStringAttribute;
            return attr.Value;
        }
    }
}
